﻿using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Windows.Data;
using ttg_internal.Utilities.UsageVisualizer.Other;

namespace ttg_internal.Utilities.UsageVisualizer.Converter
{
    /// <summary>
    /// Converts device name to its corresponding icon
    /// </summary>
    public class DeviceIconConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string fileName;
            
            if (!IconMap.Instance.DeviceMap.TryGetValue(value.ToString().ToLower(), out fileName))
            {
                fileName = IconMap.Instance.DeviceMap[string.Empty];
            }

            return Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Devices"), fileName);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
